Hi,
I have a script to load values into a table (gb) which contains a SEQUENCE ('gb_id'). For each entry into TABLE gb I need the value of 'gb_gb_id_seq' to update a relational table. I am getting the following error msg:
ERROR: gb_gb_id_seq.currval is not yet defined in this session.
If anyone knows why this is not working I would appreciate suggestions.
CREATE TABLE "gb" (
"gb_id" int4 DEFAULT nextval('"gb_gb_id_seq"'::text) NOT NULL,
"clone_id" int4,
"accn" varchar(12) NOT NULL,
"gi" int4 NOT NULL,
CONSTRAINT "gb_pkey" PRIMARY KEY ("gb_id")
);
foreach $id(sort keys %ACCN) {
$conn->exec(
"UPDATE gb SET accn_no = '$ACCN{$id}{gb}',gi_no = '$ACCN{$id}{gi}' WHERE clone_id = '$ACCN{$id}{clone_id}'"
);
$result = $conn->exec("SELECT currval('gb_gb_id_seq');");
die $conn->errorMessage unless PGRES_TUPLES_OK eq $result->resultStatus;
$gb_id = $result->fetchrow;
$ACCN{$id}{gb_id} = $gb_id;
}
--
Regards,
Charles